
'''使用说明：
1.label_input:分类label文件
2.label_output:检测label文件
3.设好变量后直接运行即可'''

label_input = 'classification label file'
label_output = 'detect label file'
labeldic = {}
with open(label_input, 'rb') as f:
    for line in f:
        line = line.decode('utf-8').strip()
        labeldic[line.split(':')[0]] = line.split(':')[1]

with open(label_output , 'w') as f:
    for i in range(len(labeldic)):
        f.writelines('item { '+'\n')
        f.writelines('    id: {}'.format(i + 1)+'\n')
        f.writelines("    name: '{}'".format('Label' + str(i))+"\n")
        f.writelines('}'+'\n')
